//
//  MyViewController.m
//  DimComDemo
//
//  Created by 于跃隆 on 2019/1/23.
//  Copyright © 2019 于跃隆. All rights reserved.
//

#import "MyViewController.h"
#import "WoDeTableCell.h"
#import "dataViewController.h"
#import "MycircleViewController.h"
#import "MyfootprintViewController.h"
#import "walletViewController.h"
#import "locationViewController.h"
#import <Masonry.h>
@interface MyViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UIImageView *imgv;
@property (nonatomic,strong)UIView *vie;
@property (nonatomic,strong)UIImageView *titImgv;
@property (nonatomic,strong)UILabel *lab;
@property (nonatomic,strong)UIImageView *img1;
@property (nonatomic,strong)UIImageView *img2;
@property (nonatomic,strong)UIImageView *img3;
@property (nonatomic,strong)UIImageView *img4;
@property (nonatomic,strong)UIImageView *img5;

@property (nonatomic,strong)UITableView *table;

@property (nonatomic,copy)NSArray *arrImg;
@property (nonatomic,copy)NSArray *arrTitle;


@end

@implementation MyViewController
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden=YES;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUI];
    self.arrImg=@[@"my_icon_information_n_hdpi",@"my_icon_circle_n_hdpi",@"my_icon_foot_n_hdpi",@"my_icon_wallet_n_hdpi",@"my_icon_address_n_hdpi"];
    self.arrTitle=@[@"个人资料",@"我的圈子",@"我的足迹",@"我的钱包",@"我的收货地址"];
    
}
-(void)setUI{
    self.imgv =[[UIImageView alloc]init];
    self.imgv.image=[UIImage imageNamed:@"Bitmap"];
    [self.view addSubview:self.imgv];
    
    self.vie=[[UIView alloc]init];
    self.vie.backgroundColor=[UIColor whiteColor];
    self.vie.layer.masksToBounds=YES;
    self.vie.layer.cornerRadius=30;
    [self.view addSubview:self.vie];
    
    self.titImgv=[[UIImageView alloc]init];
    self.titImgv.image=[UIImage imageNamed:@"Bitmap Copy"];
    [self.view addSubview:self.titImgv];
    
    self.lab=[[UILabel alloc]init];
    self.lab.font=[UIFont systemFontOfSize:16];
    self.lab.text=@"我是吃不胖的小姐姐";
    self.lab.textColor=[UIColor colorWithHexString:@"#666666"];
    [self.vie addSubview:self.lab];
    
//    self.img1=[[UIImageView alloc]init];
//    self.img1.image=[UIImage imageNamed:@"my_icon_information_n_hdpi"];
//    [self.vie addSubview:self.img1];
//
//    self.img2=[[UIImageView alloc]init];
//    self.img2.image=[UIImage imageNamed:@"my_icon_circle_n_hdpi"];
//    [self.vie addSubview:self.img2];
//
//    self.img3=[[UIImageView alloc]init];
//    self.img3.image=[UIImage imageNamed:@"my_icon_foot_n_hdpi"];
//    [self.vie addSubview:self.img3];
//
//    self.img4=[[UIImageView alloc]init];
//    self.img4.image=[UIImage imageNamed:@"my_icon_wallet_n_hdpi"];
//    [self.vie addSubview:self.img4];
//
//    self.img5=[[UIImageView alloc]init];
//    self.img5.image=[UIImage imageNamed:@"my_icon_address_n_hdpi"];
//    [self.vie addSubview:self.img5];
    
    [self.vie addSubview:self.table];
    
//    self
    
    [self addMasonry];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arrTitle.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    WoDeTableCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.Biaoti.text=self.arrTitle[indexPath.row];
    cell.titImg.image=[UIImage imageNamed:self.arrImg[indexPath.row]];
    cell.linView.backgroundColor=[UIColor lightGrayColor];
//    [cell.linView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(cell.Biaoti).offset(3);
//        make.left.mas_equalTo(cell.titImg).offset(35);
//        make.width.mas_offset(self.view.frame.size.width-35-cell.titImg.frame.size.width);
//        make.height.mas_offset(1);
//    }];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    switch (indexPath.row) {
        case 0:
            [self.navigationController pushViewController:[dataViewController new] animated:YES];
            break;
        case 1:
            [self.navigationController pushViewController:[MycircleViewController new] animated:YES];
            break;
        case 2:
            [self.navigationController pushViewController:[MyfootprintViewController new] animated:YES];
            break;
        case 3:
            [self.navigationController pushViewController:[walletViewController new] animated:YES];
            break;
        case 4:
            [self.navigationController pushViewController:[locationViewController new] animated:YES];
            break;
        default:
            break;
    }
}

-(void)addMasonry{
    [self.imgv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(-0);
        make.height.mas_equalTo(500);
        
    }];
    [self.vie mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).mas_offset(170);
        make.height.mas_equalTo(self.view.size.height-150);
        make.width.mas_equalTo(self.view.size.width);
    }];
    
    [self.titImgv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.vie).mas_offset(-50);
        make.centerX.mas_equalTo(self.vie);
        make.width.mas_offset(100);
        make.height.mas_offset(100);
        
    }];
    
    [self.lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.vie).mas_offset(70);
        make.centerX.mas_equalTo(self.vie);
        
    }];
    
   
    
    [self.table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.lab).offset(70);
        make.width.mas_offset(self.view.frame.size.width);
        make.bottom.mas_equalTo(self.view).offset(-75);
    }];
}

#pragma mark -- 懒加载
-(UITableView *)table{
    if (!_table) {
        _table=[[UITableView alloc]initWithFrame:CGRectMake(0, 50+20+70, 400, 500) style:UITableViewStylePlain];
        _table.dataSource=self;
        _table.delegate=self;
        [_table registerNib:[UINib nibWithNibName:@"WoDeTableCell" bundle:nil] forCellReuseIdentifier:@"cell"];
        _table.separatorStyle=UITableViewCellSelectionStyleNone;
//        _table.scrollEnabled=NO;
        _table.bounces=NO;
        
    }
    return _table;
}
-(void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBar.hidden=NO;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
